package com.baoteng.rbspy.model.privy;

import java.util.List;
import java.util.Optional;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.baoteng.rbspy.annotation.JsoupProperty;
import com.baoteng.rbspy.util.JsoupUtil;
import com.google.common.collect.Lists;

public class PersonUpdatePO {

	@JsoupProperty(tag = "input[name=token]")
	String token;
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.firstDate]")
	String firstDate;
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.mergeCode]")
	String mergeCode;
	/**
	 * 2 "审批通过"; 1 "待审批"; 3 "审批不通过"; 0 "未提交审批";
	 * 
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.auditStatus]")
	String auditStatus;
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.auditType]")
	String auditType;
	/**
	 * 1 "有效"; 0 "无效"; "其他";
	 * 
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.validStatus]")
	String validStatus;
	/**
	 * 客户编码
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.customerCode]")
	String customerCode;
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.versionNo]")
	String versionNo;
	/**
	 * 中文名
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.customerCName]")
	String customerCName;
	/**
	 * 英文名
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.customerFullEName]")
	String customerFullEName;
	/**
	 * 证件类型
	 */
	@JsoupProperty(tag = "input[id=oldIdentifyType]")
	String identifyType;
	
	@JsoupProperty(tag = "input[id=oldIdentifyNumber]")
	String oldIdentifyNo;
	
	/**
	 * 证件号码
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.identifyNumber]")
	String identifyNumber;
	/**
	 * 性别 1--male 2--fmale
	 */
	@JsoupProperty(tag = "input[id=oldGender]")
	String gender;
	/**
	 * 生日
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.birthDate]")
	String birthDate;
	/**
	 * 国籍 CHN
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.nationality]")
	String nationality;
	/**
	 * 证件有效期
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.dateValid]")
	String dateValid;
	/**
	 * 居民与非居民 A--居民 B--非居民
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.resident]")
	String resident="A";
	/**
	 * 是否普惠融资带动客户： 1--是 0--否
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.financeFlag]")
	String financeFlag;
	/**
	 * 风险等级： 1--高 2--中 3--低
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.creditLevel]")
	String creditLevel="3";
	/**
	 * 婚姻状况
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.marriage]")
	String marriage;
	/**
	 * 个人爱好
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.favourite]")
	String favourite;
	/**
	 * 学历代码：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.educationCode]")
	String educationCode;
	/**
	 * 健康状况：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.health]")
	String health;
	/**
	 * 身高(CM)：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.stature]")
	String stature;
	/**
	 * 体重(Kg)：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.weight]")
	String weight;
	/**
	 * 血型：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.bloodType]")
	String bloodType;
	/**
	 * 死亡日期：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.deathDate]")
	String deathDate;
	/**
	 * 客户类型：
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.customerKind]")
	String customerKind;
	/**
	 * 送审批说明
	 */
	@JsoupProperty(tag = "input[name=prpDcustomerPerson.submitDescription]")
	String submitDescription;
	List<PersonContact> contacts;
	List<PersonAddress> addresses;

	public void parser(Element doc) {
		contacts = Optional.ofNullable(contacts).orElse(Lists.newArrayList());
		Element element = doc.getElementById("PhonePersonAdd");
		if (element != null) {
			Elements elements = element.select("tbody>tr");
			elements.forEach(e -> {
				PersonContact itemPO = new PersonContact();
				JsoupUtil.newInstance().parse(e, itemPO);
				contacts.add(itemPO);
			});
		}
		addresses = Optional.ofNullable(addresses).orElse(Lists.newArrayList());
		Element _element = doc.getElementById("AddressPersonAdd");
		if (_element != null) {
			Elements elements = _element.select("tbody>tr");
			elements.forEach(e -> {
				Elements _elements = e.select("input[name=buttonInsert]");
				if(_elements==null || _elements.isEmpty()) {
					PersonAddress itemPO = new PersonAddress();
					JsoupUtil.newInstance().parse(e, itemPO);
					addresses.add(itemPO);
				}
			});
		}
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getFirstDate() {
		return firstDate;
	}

	public void setFirstDate(String firstDate) {
		this.firstDate = firstDate;
	}

	public String getMergeCode() {
		return mergeCode;
	}

	public void setMergeCode(String mergeCode) {
		this.mergeCode = mergeCode;
	}

	public String getAuditStatus() {
		return auditStatus;
	}

	public void setAuditStatus(String auditStatus) {
		this.auditStatus = auditStatus;
	}

	public String getAuditType() {
		return auditType;
	}

	public void setAuditType(String auditType) {
		this.auditType = auditType;
	}

	public String getValidStatus() {
		return validStatus;
	}

	public void setValidStatus(String validStatus) {
		this.validStatus = validStatus;
	}

	public String getCustomerCode() {
		return customerCode;
	}

	public void setCustomerCode(String customerCode) {
		this.customerCode = customerCode;
	}

	public String getVersionNo() {
		return versionNo;
	}

	public void setVersionNo(String versionNo) {
		this.versionNo = versionNo;
	}

	public String getCustomerCName() {
		return customerCName;
	}

	public void setCustomerCName(String customerCName) {
		this.customerCName = customerCName;
	}

	public String getCustomerFullEName() {
		return customerFullEName;
	}

	public void setCustomerFullEName(String customerFullEName) {
		this.customerFullEName = customerFullEName;
	}

	public String getIdentifyType() {
		return identifyType;
	}

	public void setIdentifyType(String identifyType) {
		this.identifyType = identifyType;
	}

	public String getIdentifyNumber() {
		return identifyNumber;
	}

	public void setIdentifyNumber(String identifyNumber) {
		this.identifyNumber = identifyNumber;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getBirthDate() {
		return birthDate;
	}

	public void setBirthDate(String birthDate) {
		this.birthDate = birthDate;
	}

	public String getNationality() {
		return nationality;
	}

	public void setNationality(String nationality) {
		this.nationality = nationality;
	}

	public String getDateValid() {
		return dateValid;
	}

	public void setDateValid(String dateValid) {
		this.dateValid = dateValid;
	}

	public String getResident() {
		return resident;
	}

	public void setResident(String resident) {
		this.resident = resident;
	}

	public String getFinanceFlag() {
		return financeFlag;
	}

	public void setFinanceFlag(String financeFlag) {
		this.financeFlag = financeFlag;
	}

	public String getCreditLevel() {
		return creditLevel;
	}

	public void setCreditLevel(String creditLevel) {
		this.creditLevel = creditLevel;
	}

	public String getMarriage() {
		return marriage;
	}

	public void setMarriage(String marriage) {
		this.marriage = marriage;
	}

	public String getFavourite() {
		return favourite;
	}

	public void setFavourite(String favourite) {
		this.favourite = favourite;
	}

	public String getEducationCode() {
		return educationCode;
	}

	public void setEducationCode(String educationCode) {
		this.educationCode = educationCode;
	}

	public String getHealth() {
		return health;
	}

	public void setHealth(String health) {
		this.health = health;
	}

	public String getStature() {
		return stature;
	}

	public void setStature(String stature) {
		this.stature = stature;
	}

	public String getWeight() {
		return weight;
	}

	public void setWeight(String weight) {
		this.weight = weight;
	}

	public String getBloodType() {
		return bloodType;
	}

	public void setBloodType(String bloodType) {
		this.bloodType = bloodType;
	}

	public String getDeathDate() {
		return deathDate;
	}

	public void setDeathDate(String deathDate) {
		this.deathDate = deathDate;
	}

	public String getCustomerKind() {
		return customerKind;
	}

	public void setCustomerKind(String customerKind) {
		this.customerKind = customerKind;
	}

	public String getSubmitDescription() {
		return submitDescription;
	}

	public void setSubmitDescription(String submitDescription) {
		this.submitDescription = submitDescription;
	}

	public List<PersonContact> getContacts() {
		return contacts;
	}

	public void setContacts(List<PersonContact> contacts) {
		this.contacts = contacts;
	}

	public List<PersonAddress> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<PersonAddress> addresses) {
		this.addresses = addresses;
	}

	public String getOldIdentifyNo() {
		return oldIdentifyNo;
	}

	public void setOldIdentifyNo(String oldIdentifyNo) {
		this.oldIdentifyNo = oldIdentifyNo;
	}

}
